package com.example.xiangmuservice.service.impl;


import com.example.xiangmuservice.dao.AppRepository;
import com.example.xiangmuservice.entity.App;
import com.example.xiangmuservice.service.AppService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Optional;

@Service
public class AppServiceImpl implements AppService {
    @Autowired
    AppRepository appRepository;


    @Override
    public App insertApp (App app){
        return appRepository.save(app);
    }

    @Override
    public App findById(Integer id) {
//        System.out.println("进入控制层，主要做业务处理，比如，我要把id变成3，不管传入的是什么");
//        id = 3;
//        System.out.println("控制层要做的事情已经完成了，调用模型层（实际对数据库操作的层）的函数，进行CRUD");
        Optional<App> optional = appRepository.findById(id);
        if (optional.isPresent()){
            return optional.get();
        }
        return null;
    }


}
